﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace InSafetyAirClient.GUI
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void listBoxP_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxP.SelectedIndex)
            {
                case 0:
                    {
                        createP1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updateP1.BringToFront();
                        break;
                    }
                case 2:
                    {
                        listP1.BringToFront();
                        break;
                    }
                case 3:
                    {
                        deleteP1.BringToFront();
                        break;
                    }
                    
            }
        }

        private void listBoxPM_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxPM.SelectedIndex)
            {
                case 0:
                    {
                        createPM1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updatePM1.BringToFront();
                        break;
                    }
                case 2:
                    {
                        listPM1.BringToFront();
                        break;
                    }
                case 3:
                    {
                        deletePM1.BringToFront();
                        break;
                    }

            }
        }

        private void listBoxA_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxA.SelectedIndex)
            {
                case 0:
                    {
                        createA1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updateA1.BringToFront();
                        break;
                    }
                case 2:
                    {
                        listA1.BringToFront();
                        break;
                    }
                case 3:
                    {
                        deleteA1.BringToFront();
                        break;
                    }

            }
        }

        private void listBoxAip_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxAip.SelectedIndex)
            {
                case 0:
                    {
                        createAip1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updateAip1.BringToFront();
                        break;
                    }
                case 2:
                    {
                        listAip1.BringToFront();
                        break;
                    }
                case 3:
                    {
                        deleteAip1.BringToFront();
                        break;
                    }

            }
        }

        private void listBoxAP_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxAP.SelectedIndex)
            {
                case 0:
                    {
                        createAP1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updateAP1.BringToFront();
                        break;
                    }
                case 2:
                    {
                        listAP1.BringToFront();
                        break;
                    }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            InSafetyAirService.Account ac = ServiceSingle.Instance.getService().checkLogin(textBox1.Text,textBox2.Text);
            if (ac == null)
            {
                label2.Text = "Invalid login!";
            }
            else
            {
                if (ac.access == 0)
                    label2.Text = "Invalid clearance!";
                else
                    fundal.BringToFront();
            }
        }

        private void listBoxF_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (listBoxF.SelectedIndex)
            {
                case 0:
                    {
                        createF1.BringToFront();
                        break;
                    }
                case 1:
                    {
                        updateF1.BringToFront();
                        break;
                    }
            }
        }
    }
}
